package com.yk.airline.util;/**
 * Created by wangzhili on 2018/2/1.
 */

import java.util.Comparator;
import java.util.Map;

/**
 * Project Name:airlinecrawler
 * File Name:AnalysisDataModelComparator
 * Package Name:com.yk.airline.util
 * Date:2018/2/1 11:53
 * Author:wangzhili
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */

public class AnalysisDataModelComparator implements Comparator<Map<String,String>> {
    @Override
    public int compare(Map<String, String> first, Map<String, String> second) {
        String firstAirLine=first.get("flightLine");
        String secondAirLine=second.get("flightLine");

        if(firstAirLine.compareTo(secondAirLine)==0){
            if(first.get("airCompany").compareTo(second.get("airCompany"))==0){
                return first.get("flightNumber").compareTo(second.get("flightNumber"));
            }else {
                return first.get("airCompany").compareTo(second.get("airCompany"));
            }
        }
        else
            return firstAirLine.compareTo(secondAirLine);
    }
}
